# -*- coding: utf-8 -*-
# owner: shenyi
# file: src/providers/aws/client.py

from calendar import c
import boto3
from src.core import credentials

class Client:
    @staticmethod
    def ec2_client(region = None):
        # 全局 boto3 session（线程安全，可复用）
        aws_creds = credentials().aws()
        _session = boto3.Session(
            aws_access_key_id=aws_creds.get("access_key_id"),
            aws_secret_access_key=aws_creds.get("secret_access_key")
        )
        region = region or aws_creds.get('region')
        return _session.client('ec2', region_name=region)